//
//  DutyScreeningView.m
//  Nurse
//
//  Created by zhangp on 13-12-17.
//  Copyright (c) 2013年 RainSets. All rights reserved.
//

#import "DutyScreeningView.h"
#import "ScreeningTitleCell.h"
#import "DutyScreeningViewCell.h"



@interface DutyScreeningView ()

@end

@implementation DutyScreeningView


-(void)setViewStyle{
    self.backgroundColor=[UIColor clearColor];
    self.bgimg.backgroundColor=[UIColor whiteColor];
    self.table_View.showsVerticalScrollIndicator=NO;//竖线
    self.table_View.frame=CGRectMake(0, 20, self.table_View.frame.size.width, self.frame.size.height-20);
    
    
}





-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    
    CGPoint touch=[[touches anyObject] locationInView:self];
    if (touch.x>0 && touch.y>0) {
        
       [self removeFromSuperview];
        
    }
    
}





- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
	
    
    if (indexPath.row==0) {
        return 50;
    }else{
       
            return 60;
       
    }

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
  
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0) {
        return 5;
    }else{
         return 4;
    }
   
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.row==0) {
        static NSString *CellIdentifier = @"ScreeningTitleCell";
        
        ScreeningTitleCell *cell = (ScreeningTitleCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(cell==nil){
            
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ScreeningTitleCell" owner:self options:nil];
            cell = [nib objectAtIndex:0];
           
            
        }
        if (indexPath.section==0) {
            cell.titleLabel.text=@"类型";
        }else{
            cell.titleLabel.text=@"状态";
        }
        
        
        
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
    }else{
        static NSString *CellIdentifier = @"DutyScreeningViewCell";
        
        DutyScreeningViewCell *cell = (DutyScreeningViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(cell==nil){
            
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DutyScreeningViewCell" owner:self options:nil];
            cell = [nib objectAtIndex:0];

            
        }
        
        
        
        if (indexPath.section==0) {
            cell.img.hidden=NO;
            cell.contentLab.frame=CGRectMake(83, 19, 91, 21);
           
            cell.hookImg.image=[UIImage imageNamed:@"current-icon.png"];//sure_btn.png
            
            
            switch (indexPath.row) {
                case 1:
                {
                    cell.contentLab.text=@"全部";
                    cell.img.image=[UIImage imageNamed:@"task-icon-all.png"];
                
                }
                    break;
                case 2:
                {
                    cell.contentLab.text=@"检验";
                     cell.img.image=[UIImage imageNamed:@"task-icon-01.png"];
                }
                    break;
                case 3:
                {
                    cell.contentLab.text=@"用药";
                     cell.img.image=[UIImage imageNamed:@"task-icon-02.png"];
                }
                    break;
                case 4:
                {
                    cell.contentLab.text=@"护理";
                     cell.img.image=[UIImage imageNamed:@"task-icon-03.png"];
                }
                    break;
                    
                default:
                    break;
            }
            
            
            
            if (indexPath.row-1==self.typeChoose) {
                cell.contentLab.textColor=[UIColor whiteColor];
                cell.hookImg.hidden=NO;
                if (self.typeChoose==0)
                {
                cell.bgimg.backgroundColor=[UIColor colorWithRed:155/255.0 green:236/255.0 blue:229/255.0 alpha:1];
                }
                if (self.typeChoose==1)
                {
                    cell.bgimg.backgroundColor=[UIColor colorWithRed:249/255.0 green:210/255.0 blue:116/255.0 alpha:1];
                }
                if (self.typeChoose==2)
                {
                    cell.bgimg.backgroundColor=[UIColor colorWithRed:246/255.0 green:138/255.0 blue:166/255.0 alpha:1];
                }
                if (self.typeChoose==3)
                {
                    cell.bgimg.backgroundColor=[UIColor colorWithRed:178/255.0 green:192/255.0 blue:246/255.0 alpha:1];
                }

            }else{
                cell.contentLab.textColor=[UIColor blackColor];
                cell.hookImg.hidden=YES;
                cell.bgimg.backgroundColor=[UIColor whiteColor];
            }
        }else{
            cell.img.hidden=YES;
            cell.contentLab.frame=CGRectMake(20, 19, 91, 21);
            cell.hookImg.image=[UIImage imageNamed:@"current-icon.png"];//sure_btn.png
            
            switch (indexPath.row) {
                case 1:
                {
                    cell.contentLab.text=@"全部";
                }
                    break;
                case 2:
                {
                    cell.contentLab.text=@"已完成";
                }
                    break;
                case 3:
                {
                    cell.contentLab.text=@"未完成";
                }
                    break;
               
                    
                default:
                    break;
            }
            
            if (indexPath.row-1==self.stateChoose) {
                cell.contentLab.textColor=[UIColor whiteColor];
                cell.hookImg.hidden=NO;
                cell.bgimg.backgroundColor=[UIColor colorWithRed:76/255.0 green:214/255.0 blue:193/255.0 alpha:1];
            }else{
                cell.contentLab.textColor=[UIColor blackColor];
                cell.hookImg.hidden=YES;
                cell.bgimg.backgroundColor=[UIColor whiteColor];
            }
        }
        

        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
    }
   
    

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row>0) {
        //[self removeFromSuperview];
        
        if (indexPath.section==0) {
            self.typeChoose=indexPath.row-1;
        }else{
            self.stateChoose=indexPath.row-1;
        }
        [tableView reloadData];
        
        
//        dispatch_queue_t downloadQueue = dispatch_queue_create("sleepForTimeInterval ", NULL);
//        dispatch_async(downloadQueue, ^{
//          
//            [NSThread sleepForTimeInterval:0.7];
//            
//           dispatch_async(dispatch_get_main_queue(), ^{
//              
//                 [self removeFromSuperview];
//                
//            });
//            
//        });
       
        
        
        
    }
    
    
}






@end
